﻿using JetBrains.Annotations;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
using TianShu.Domain.Entities;

namespace TianShu.TenantManagement.Dal.Abstracts.Entities
{
    [SugarTable("tianshu_tenant_connection_string")]
    public class TenantConnectionStringEntity : Entity<Guid>
    {
        [SugarColumn(IsNullable = false, Length = 36)]
        public virtual Guid TenantId { get; protected set; }

        [SugarColumn(IsNullable = false, Length = 64)]
        public virtual string Name { get; protected set; }

        [SugarColumn(IsNullable = false, Length = 1024)]
        public virtual string Value { get; protected set; }

        public TenantConnectionStringEntity()
        {

        }

        public TenantConnectionStringEntity(Guid tenantId, [NotNull] string name, [NotNull] string value)
        {
            TenantId = tenantId;
            Name = Check.NotNullOrWhiteSpace(name, nameof(name), 64);
            SetValue(value);
        }

        public virtual void SetValue([NotNull] string value)
        {
            Value = Check.NotNullOrWhiteSpace(value, nameof(value), 1024);
        }

        public override object[] GetKeys()
        {
            return new object[] { TenantId, Name };
        }
    }
}
